@extends('layouts.public')

@section('head')
    <link rel="stylesheet" href="{{cdn('js/plugins/webuploader/single.css')}}">
@endsection

@section('bodyattr')class="gray-bg"@endsection

@section('body')
    <div class="wrapper wrapper-content">
        <div class="row m-b">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li><a href="{{route('admin.shop.shops')}}">求购列表</a></li>
                        <li @if(!isset($user))class="active"@endif><a href="{{route('admin.shop.shops.add')}}">新增</a></li>
                        @if(isset($user))
                            <li class="active"><a href="#">编辑</a></li>
                        @endif
                    </ul>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form action="{{route('admin.buy.buys.save')}}" method="post" class="form-horizontal ajaxForm">
                            <input type="hidden" name="id" value="{{$user->id or 0}}"/>
                           
                            <div class="form-group">
                                <label class="col-sm-2 control-label">标题</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="title" @if(isset($user)) value="{{$user->title or ''}}"placeholder="请填写标题名称" @endif autocomplete="off"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">作者</label>
                                <div class="col-sm-3">
                                    <select name="author_id" class="form-control">
                                        <option value="">请选择作者</option>
                                        @foreach ($cates as $cate)
                                            <option value="{{$cate['uid']}}"
                                                    @if ((isset($user->user_id) ? $user->user_id : '') == $cate['uid']) selected="selected"@endif>
                                                &nbsp;&nbsp;&nbsp;&nbsp;{{$cate['nickname']}}</option>

                                        @endforeach
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">截止时间</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="endDate" id="endDate"   @if(isset($user)) value="{{$user->endDate or ''}}" placeholder="请选择时间"  @endif autocomplete="off"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">尺寸</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="size"   @if(isset($user)) value="{{$user->size or ''}}" placeholder="请填写尺寸尺寸"  @endif autocomplete="off"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">所需数量</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" name="need_nums"   @if(isset($user)) value="{{$user->need_nums or ''}}" placeholder="请填写数量"  @endif autocomplete="off"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">求购简介</label>
                                <div class="col-sm-3">
                                    <textarea  class="form-control" name="des" @if(isset($user)) value="{{$user->des or ''}}"placeholder="请填写求购简介" @endif ></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">备注</label>
                                <div class="col-sm-3">
                                    <textarea  class="form-control" name="remark" @if(isset($user)) value="{{$user->remark or ''}}"  @endif ></textarea>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                    <button class="btn btn-white" type="button" id="backBtn">返回</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript" src="{{cdn('js/plugins/laydate/laydate.js')}}"></script>
    <script type="text/javascript">
        laydate.render({
            elem: '#endDate',
            type: 'datetime',
            max: 15
        });
    </script>
@endsection